
classdef SocketClientForLMS
    properties
        port
        host
        clientSocket
        iStream
        oStream
    end
    
    methods
        function this = SocketClientForLMS(port,host)
            import java.net.*;
            import java.io.*;
            
            this.port = port;
            this.host;
            disp('Connecting to server...')
            this.clientSocket = Socket(host, this.port);
            
            this.iStream = this.clientSocket.getInputStream;
            this.oStream = this.clientSocket.getOutputStream;
            
            
            
            % Greets the server on connection is accepted
            
            
        end
        
        
        function sent = sendLMS(serverLMS,nbpts,resolution,datar,dataa)

            trame = 'LMS';
            for i=1:size(datar)
                %disp(int16(datar(i)*1000))
                trame = strcat(trame,',');
                trame = strcat(trame,num2str(int16(datar(i)*1000)));
            end
            trame = strcat(trame,',');
            for i=length(trame):2:904
                trame = strcat(trame,num2str(((0))));
            end
            
            serverLMS.oStream.sendS(trame);
            %while ~(serverLMS.iStream.available)
                
            %end
         sent = 1;
            
            
        end
    end
end
